package com.wdd.recoveryvehicle.menuItem.service.impl;

import com.wdd.recoveryvehicle.mapper.MenuItemMappler;
import com.wdd.recoveryvehicle.menuItem.bean.MenuItemVB;
import com.wdd.recoveryvehicle.menuItem.service.MenuItemService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 菜单列表
 */
@Service
public class MenuItemServiceImpl implements MenuItemService {

    @Autowired
    private MenuItemMappler menuItemMappler;

    /**
     * 查询 菜单列表
     * @return
     */
    @Override
    public List<MenuItemVB> selectMenuItem() {
        List<MenuItemVB> parentMenu = menuItemMappler.selectParentList();
        if (parentMenu!=null && parentMenu.size()>0){
            for (MenuItemVB parent: parentMenu) {
                List<MenuItemVB> child = menuItemMappler.selectChildList(parent.getId());
                parent.setChild(child);
            }
        }
        return parentMenu;
    }
}
